package cloud.xlh.digital_power_order.disruptor;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2023/8/22 21:59
 * @ Description:
 */
import cloud.xlh.digital_power_order.domian.order.OrderSaveDomain;
import cloud.xlh.digital_power_order.infrastructure.order.entity.OrderEntity;
import com.lmax.disruptor.RingBuffer;
import org.springframework.stereotype.Component;

@Component
public class Producer {
    private final RingBuffer<OrderEntity> ringBuffer;
    public Producer(RingBuffer<OrderEntity> ringBuffer){
        this.ringBuffer = ringBuffer;
    }
    public void onData(OrderSaveDomain orderSaveDomain){
        long sequence = ringBuffer.next();
        try {
            OrderEntity orderEntity = ringBuffer.get(sequence);
            //todd 转化
        } finally {
            ringBuffer.publish(sequence);
        }
    }
}
